<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Foundation\Auth\User;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Log;
use App\Models\System;
class IndexController extends Controller
{
    public function index()
    {
        $user_count = System::where('id','=',1)->first();
        if(!$user_count) {
            $user_count =System::create(array('user_count'=>0));
        }
        return view('admin.index.index',compact('user_count'));
    }

    public function count(Request $request){
            $id = $request->get('id');
            $user_count =  System::find($id);
            $user_count->user_count = $request->get('user_count');
            $user_count->update();
            return redirect('/admin/index')->withSuccess('修改成功！');
    }
}
